a = input().replace(' ', '')
for sim in a:
    if sim != '(' and sim != ')' and sim != '[' and sim != ']' and sim != '{' and sim != '}' and sim != '<' and sim != '>':
        a = a.replace(sim, '')
while '{}' in a or '[]' in a or '()' in a or '<>' in a:
    a = a.replace('[]', '')
    a = a.replace('{}', '')
    a = a.replace('()', '')
    a = a.replace('<>', '')
if len(a) > 0:
    print('False')
else:
    print('True')